package com.alibaba.cloud.ai.example.manus.schedule.repository;


import com.alibaba.cloud.ai.example.manus.schedule.entity.ScheduleJob;
import com.alibaba.cloud.ai.example.manus.schedule.enums.JobStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;

@Repository
public interface ScheduleJobRepository extends JpaRepository<ScheduleJob, Long> {

    Optional<ScheduleJob> findByJobNameAndJobGroup(String jobName, String jobGroup);

    List<ScheduleJob> findByStatus(JobStatus status);

    @Query("SELECT j FROM ScheduleJob j WHERE j.status != 'DELETED'")
    List<ScheduleJob> findAllActive();

    boolean existsByJobNameAndJobGroup(String jobName, String jobGroup);
}
